﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Ymatou.File.Lib
{
    public class TypeExsitsAttribute : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext authContext)
        {
            string type = "";

            if (authContext.RouteData.Values["type"] != null)
            {
                type = authContext.RouteData.Values["type"].ToString();
            }

            if (authContext.RequestContext.HttpContext.Request.QueryString["type"] != null)
            {
                type = authContext.RequestContext.HttpContext.Request.QueryString["type"];
            }

            if (string.IsNullOrEmpty(type))
            {
                authContext.Result = new ContentResult() { Content = "Error:类型不可以为空" };
            }
        }
    }
}